package com.chen.Sign.controller;

import com.chen.Sign.common.Result;
import com.chen.Sign.mapper.Blog_tagMapper;
import com.chen.Sign.service.Blog_tagService;
import com.chen.Sign.service.impl.Blog_tagServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;

// 博客标签模块
@RestController
@Slf4j
@SuppressWarnings({"all"})
@RequestMapping("/Blogtag")
public class Blog_tagController {

    @Autowired
    Blog_tagServiceImpl blog_tagService;

    @Autowired
    RedisTemplate redisTemplate;


    // 添加标签
    @PostMapping("/addtag")
    public Result addtag(HttpServletRequest request) {
        Result result = new Result();
        String[] tags1 = request.getParameterValues("tag");
        String tags = Arrays.toString(tags1);
        String tag = tags.substring(1, tags.length() - 2);
        boolean addtag = blog_tagService.addtag(tag);
        if (addtag) {
            return result.addtagok("");
        } else {
            return result.addtagno("");
        }
    }
}
